package cn.dida.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.dida.dao.PrizeDao;
import cn.dida.model.Branch;
import cn.dida.model.Pageable;
import cn.dida.model.Prize;
import cn.dida.model.PrizeBranch;
import cn.dida.service.PrizeService;
/**
 * 奖品  接口实现类
 * @author lisha
 * @date 2016-11-10 16:13
 * */
@Service
public class PrizeServiceImpl implements PrizeService {

	@Autowired
	private PrizeDao prizeDao;
	@Transactional	
	@Override
	public Boolean insertPrize(Prize prize) {
		// TODO Auto-generated method stub
		return prizeDao.insert(prize) == 1;
	}
	@Transactional
	@Override
	public Boolean updatePrize(Integer companyId,Prize prize) {
		// TODO Auto-generated method stub
		return prizeDao.update(companyId,prize) == 1;
	}
	@Transactional
	@Override
	public Boolean deletePrizeById(Integer companyId,int id) {
		// TODO Auto-generated method stub
		return prizeDao.delete(companyId,id) == 1;
	}

	@Override
	public Prize getPrizeById(Integer id, Integer companyId) {
		// TODO Auto-generated method stub
		return prizeDao.getPrizeById(id, companyId);
	}

	@Override
	public Pageable<Prize> queryPrize(Integer companyId,String name, int type,int page) {
		// TODO Auto-generated method stub
		return prizeDao.query(companyId,name, type, page);
	}

	@Override
	public List<Prize> queryPrize(Integer companyId) {
		// TODO Auto-generated method stub
		return prizeDao.query(companyId);
	}

	@Override
	public List<Branch> getBranchListByPrizeId(String prizeId) {
		// TODO Auto-generated method stub
		return prizeDao.getBranchListByPrizeId(prizeId);
	}
	@Transactional
	@Override
	public Boolean deleteBranchById(Integer branchId) {
		// TODO Auto-generated method stub
		return prizeDao.deleteBranchById(branchId) == 1;
	}

	@Override
	public List<PrizeBranch> getPrizeBranchListByPrizeId(Integer prizeId) {
		// TODO Auto-generated method stub
		return prizeDao.getPrizeBranchListByPrizeId(prizeId);
	}

	@Override
	public boolean isExistsPrize(Integer companyId, String name) {
		// TODO Auto-generated method stub
		return prizeDao.isExistsPrize(companyId, name);
	}

}
